
local SGame=Class()

function SGame:Construct()
    self.BtnRegister.OnClicked:Add(self,self.Register)
    self.BtnReturnLogin.OnClicked:Add(self,self.ReturnLogin)
    GetGameIns(self).m_RegisterAccountSuccess:Add(self,self.AAA)
end

function SGame:AAA()
    Warning("注册成功")
end

function SGame:Register()
    if GetStringLength(self.TextAccount:GetText())>=10 then
        Err("账号长度超过10")
        return
    end
    if GetStringLength(self.TextAccount:GetText())<=5 then
        Err("账号长度小于5")
        return
    end
    if self.TextPassword1:GetText()~=self.TextPassword2:GetText() then
        Err("密码输入不一致")
        return
    end
    if GetStringLength(self.TextPassword1:GetText())<=5 then
        Err("密码长度小于5")
        return
    end
    if GetStringLength(self.TextPassword1:GetText())>=10 then
        Err("密码长度大于10")
        return
    end
    if GetMySQLSub(self):CanRegisterPlayerName(self.TextAccount:GetText()) then
        local MessagePak=UE4.FLoginMessage()
        MessagePak.Account=self.TextAccount:GetText()
        MessagePak.Password=self.TextPassword1:GetText()
        MessagePak.ReturnID=-1
        GetMySQLSub(self):RegisterAccount(MessagePak)
    else
        Err("账号已经注册")
        return  
    end
    
    
end

function SGame:ReturnLogin()
    UI.GetUI("login").SwitchWidget:SetActiveWidgetIndex(0)
end
--SwitchWidget

return SGame